<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      >
<head th:replace="fragments/tabhead::headc"></head>

<body>

<th:block layout:fragment="content">
<!-- 销售订单 -->
<div style="margin-top:10px">
  <form class="layui-form search" id="searchForm">
  <div class="layui-form-item layui-elem-quote">
     <div class="layui-inline">
      <label class="layui-form-label" style="width:100px">所属公司</label>
      <div class="layui-input-inline">
        <select name="companyId"><option value="1">深圳企智达有限公司</option></select>
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label" style="width:80px">供应商</label>
      <div class="layui-input-inline" style="width:100px">
        <input type="tel" name="customerName" class="layui-input"/>
      </div>
    </div>
   <div class="layui-inline">
      <label class="layui-form-label" style="width:100px">审核状态</label>
      <div class="layui-input-inline" style="width:100px;">
        <select name="reviewStatus">
        	<option value="1">已审核</option>
        </select>
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label" style="width:60px">时间</label>
      <div class="layui-input-inline" style="width:100px">
        <input type="text" id="startDate" class="layui-input" name='startDate'/>
      </div>
       <div class="layui-form-mid">-</div>
      <div class="layui-input-inline" style="width:100px">
        <input type="text" id="endDate" class="layui-input" name="endDate"/>
      </div>
    </div>
	
    <div class="layui-inline">
      <div class="layui-input-inline" style="width:60px;">
        <button class="layui-btn" id="searchBtn" type="button">查询</button>
      </div>
    </div>
    
  </div>
 </form>
</div>

<table class="layui-table"  id="tab" lay-filter="tab">
</table>
<script>
var ins,page,trobj,editdialogindex,adddialogindex;
$(function(){ 
	
	layui.use(['table','layer','laypage'], function(){
		var table = layui.table;
		var laypage = layui.laypage;
		ins =table.render({ //其它参数在此省略
		 elem:"#tab",
		 url: '/pu/purchaseorder/list?first=true',
		 cols:[[
			   //fixed 列将会被固定在左或右，不随滚动条而滚动left right
			  {field:'orderNo',width:120, sort: true,title:'单号',fixed:"left"},
		      {field:'companyName', width:180,title:'所属公司'},
		      {field:'sourceOrderNo', width:120, sort: true,title:'来源单号'},
		      {width:177,field:'supplierName',title:'供应名称'},
		      {field:'supplierConnact', width:80, sort: true,title:'供应商联系人'},
		      {field:'phone', width:120, title:'联系电话'},
		      {field:'address', width:80,title:'到货地址'},
		      {field:'settleMethodName', width:125,title:'结算方式'},
		      {field:'settleDays', width:125,title:'结算天数'},
		      {field:'settleCurrencyName', width:125,title:'币种'},
		      {field:'exchargeRate', width:125,title:'汇率'},
		      {field:'taxRate', width:125,title:'税率',templet:"#taxTpl"},
		      {field:'count', width:125,title:'订单总量'},
		      {field:'totalPriceNotIncludingTax', width:140,title:'订单未税总金额'},
		      {field:'priceIncludingTax', width:140,title:'订单含税总金额'},
		      {field:'statusStr', width:80, title:'状态'},
		      {field:'confirmPerson',width:177,title:'审核人'},
		      {field:'confirmDate', width:160, title:'审核日期'},
		      {field:'modifyPerson', width:80, title:'修改人'},
		      {field:'mofifyDate', width:160,title:'修改日期'},
		      {field:'createPerson', width:135, title:'创建人'},
		      {field:'createDate', width:160, title:'创建日期'},
		      {field:'remark', width:135, title:'备注'},
		      {align:'center',fix:'right',width:80, toolbar:'#toolbar',title:'操作',fixed:"right"}
		 ]]
	    ,page: true //是否显示分页
	    ,limits: [10,20,50]
	    ,limit:10 //每页默认显示的数量
		  //where:{phone:phone}
		 ,method: 'post'
		 ,done:function(res,curr,count){
			 console.log(res);
			 page = curr;
			    //得到当前页码
			 console.log(curr); 
			    //得到数据总量
			 console.log(count);
		 }
		});
		
		table.on("tool(tab)",function(obj){
			var data = obj.data; //获得当前行数据
			var layEvent = obj.event; //获得 lay-event 对应的值
			trobj = obj;
			var tr = obj.tr; //获得当前行 tr 的DOM对象
			if(layEvent=='select'){
				$.post('/stock/puoutbound/puedit/1/'+data.id, {}, function(str){
				editdialogindex = layer.open({
									title:"确认选择来源单",
								    type: 1,
								    area: ['680px', '500px'],
								    content: str,//注意，如果str是object，那么需要字符拼接。
								    zIndex:10
								  });
								});
			}
		});
		
		
		//查询按钮点击
		$("#searchBtn").click(function(){
			var table = layui.table;
		    ins.reload({url: '/pu/purchaseorder/list',where:$("#searchForm").serializeJson()})
		});
		
	})
	
	layui.use("laydate",function(){
		var laydate = layui.laydate;
		laydate.render({
			  elem: '#startDate' //指定元素
			});
		laydate.render({
			  elem: '#endDate' //指定元素
			});
	});
}); 
function reloadData(){
	$(".layui-laypage-btn")[0].click();
}
</script>
<script type="text/html" id="toolbar">
	<a class="layui-btn layui-btn-mini" lay-event="select">选择</a>
</script>
<script type="text/html" id="taxTpl">
<span>{{d.taxRate}}%</span>
</script>
<!--<div th:replace="department/model::modelDiv"></div>-->
</th:block>
</body>
</html>